package com.ssy.lingxi.platform.manage.controller.content;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.entity.content.ContentCategory;
import com.ssy.lingxi.platform.manage.model.request.common.CommonIdRequest;
import com.ssy.lingxi.platform.manage.model.request.content.ContentCategoryRequest;
import com.ssy.lingxi.platform.manage.model.response.ContentCategoryResponse;
import com.ssy.lingxi.platform.manage.service.content.IContentCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @menu 内容管理 - 分类管理
 * @author fhj
 * @version 2.0.0
 * @date 2021/04/25
 */
@Api(tags = "内容管理 - 分类管理")
@RestController
@RequestMapping("/manage/contentCategory")
public class ContentCategoryController extends BaseController {

    @Resource
    private IContentCategoryService contentCategoryService;

    @ApiOperation(value = "所有")
    @GetMapping("/all")
    public Wrapper<List<ContentCategoryResponse>> all() {
        return contentCategoryService.all();
    }

    @ApiOperation(value = "详情")
    @GetMapping(value = "/get")
    public Wrapper<ContentCategory> get(@Validated CommonIdRequest request) {
        return contentCategoryService.get(request);
    }

    @ApiOperation(value = "新增")
    @PostMapping(value = "/add")
    public Wrapper<Void> add(@RequestBody @Validated({ContentCategoryRequest.Add.class}) ContentCategoryRequest request) {
        return contentCategoryService.add(request, getSysUser());
    }

    @ApiOperation(value = "修改")
    @PostMapping(value = "/update")
    public Wrapper<Void> update(@RequestBody @Validated({ContentCategoryRequest.Update.class}) ContentCategoryRequest request) {
        return contentCategoryService.update(request, getSysUser());
    }

    @ApiOperation(value = "删除")
    @PostMapping(value = "/delete")
    public Wrapper<Void> delete(@RequestBody @Validated CommonIdRequest request) {
        return contentCategoryService.delete(request, getSysUser());
    }

    @ApiOperation(value = "推荐分类")
    @GetMapping("/recommend")
    public Wrapper<List<ContentCategoryResponse>> recommend() {
        return contentCategoryService.recommend();
    }
}
